//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace TridentMonitorApplication
{
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Windows;
    using Microsoft.Research.ScientificWorkflow.TridentUtilities;
    using System.Globalization;

    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        /// <summary>
        /// Event handler for capturing the command line arguments.
        /// </summary>
        /// <param name="sender">Applicatioon.</param>
        /// <param name="commandParams">Commnad line Parameters.</param>
        private void Application_Startup(object sender, StartupEventArgs commandParams)
        {
            string usageHelp = string.Format(CultureInfo.CurrentUICulture, "Usage:{0} -job jobId", AppDomain.CurrentDomain.FriendlyName);

            if (commandParams.Args.Length < 2 || !commandParams.Args.Contains("-job"))
            {
                TridentMessageBox.ShowTridentErrorMessageBox(usageHelp);
                Environment.Exit(1);
            }

            // Add the Passed in Job ID to the application level Properties.
            this.Properties.Add("CurrentJobID", commandParams.Args[Array.IndexOf(commandParams.Args, "-job") + 1]);
        }
    }
}
